package com.netty.nio.zerocopy;

import java.io.DataInputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

//java IO 的服务器
public class OldIOServer {
    public static void main(String[] args) throws IOException {
        //传统的IO
        //创建serversocket
        ServerSocket serverSocket = new ServerSocket(7001);
        //监听
        while (true) {
            Socket socket = serverSocket.accept();
            //获取数据传输流
            DataInputStream dataInputStream = new DataInputStream(socket.getInputStream());
            try {
                //创建byte数组
                byte[] byteArray = new byte[4096];
                while (true){
                    //读取数据
                    int readCount = dataInputStream.read(byteArray, 0, byteArray.length);
                    if (-1 == readCount){
                        break;
                    }
                }
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }
}